package top.fzqblog.util;

import org.simpleframework.xml.Serializer;
import org.simpleframework.xml.convert.AnnotationStrategy;
import org.simpleframework.xml.core.Persister;
import org.simpleframework.xml.strategy.Strategy;

/**
 * Created by 抽离 on 2017/10/13 0013.
 */

public class XmlUtil {

    public static Object getXMLObject(String result, Class<?> clazz) {

        Object o = null;
        result = result.replace("&", "&amp;");
        Strategy strategy = new AnnotationStrategy();
        Serializer serializer = new Persister(strategy);
        try {
            o = serializer.read(clazz, result);
        } catch (Exception e) {
            e.printStackTrace();
        }

        return o;
    }
}
